<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Customer</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container" id="app">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>场景日志</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="" lay-filter="table-search">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">选择区服:</label>
                            <div class="layui-input-inline">
                                <select name="gameArea" class="layui-select" >

                                    <option v-for="(item,index) in services" :value="item.server_id" :selected="index==0">{{item.name}}</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">账号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="account" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">角色名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="roleName" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">角色ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="roleId" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">物品名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="equipName" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">物品ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="equipId" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">物品唯一ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="uuid" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">记录时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="createTimeBegin" id="createTime0"
                                       placeholder="开始时间" autocomplete="off" class="layui-input" />
                                <input type="text" name="createTimeEnd" id="createTime1"
                                       placeholder="截止时间" autocomplete="off" class="layui-input" />
                            </div>
                        </div>

                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn">
                                <i class="layui-icon"></i>搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>
<style>
    .layui-table-cell { /*自适应行高*/
        height: auto !important;
        white-space: normal;
    }
</style>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/common.js?v=5" charset="utf-8"></script>
<script id="zbsx" type="text/html">
    {{#    if(!d.attr){    }}
    <p>未记录</p>
    {{# }else{ }}
    <p>C: {{d.attr.gem_count}}</p>
    {{#     layui.each(d.attr.attr,function(index,item){    }}
    <p>{{getEquipAttrName(item.key)}}:{{item.value}}</p>
    {{#     });                                            }}
    {{#     }                                    }}
</script>

<script id="clmx" type="text/html">
    {{#     layui.each(d.use_material,function(index,item){    }}
    <p>{{getEquipName(item.id)}}:{{item.count}}</p>
    {{#     });                                            }}
</script>

<script>
    var equipments = getEnum('equip')
    var equipAttrs = getEnum('equipAttr')
    function getEquipAttrName(id){
        for(var k in equipAttrs){
            if (equipAttrs[k].id === id){
                return equipAttrs[k].name;
            }
        }
        return id;
    }

    function getEquipName(itemId) {
        for(var k in equipments){
            if (equipments[k].id === itemId){
                return equipments[k].name;
            }
        }
        return itemId;
    }

    var coinChangeTypes = []
    new Vue({
        el: "#app",
        data: {
            services: JSON.parse(localStorage.getItem('services')),
        },
        mounted: function () {
            layui.use(['form', 'table','laydate'], function () {
                var $ = layui.jquery,
                    form = layui.form,
                    table = layui.table,
                    laydate=layui.laydate;
                laydate.render({
                    elem: '#createTime0',
                    value: getYmd(0)
                });
                laydate.render({
                    elem: '#createTime1',
                    value: getYmd(1)
                })
                var data = [];
                for(var k in coinChangeTypes){
                    var v = coinChangeTypes[k];
                    data.push({
                        name:v.value,
                        value:v.key,
                    })
                }

                table.render({
                    elem: '#currentTableId',
                    width:1700,
                    where:form.val('table-search'),
                    url: '/admin/equipIntensify/paginate',
                    defaultToolbar: ['filter', 'print'],
                    toolbar: 'default0',
                    cols: [[
                        {type: "checkbox", width: 50},
                        {field: 'logTime', width:165,title:'记录时间',templet:function(row){
                                return getYMDHMS(row.logTime)
                            }},
                        {field: 'serverId', title:'服务器ID'},
                        {field: 'account', title:'游戏账号',templet:function (row) {
                                return row.member?row.member.username:null;
                            }},
                        {field: 'roleId', title:'角色ID'},
                        {field: 'nick', title:'角色名'},
                        {field: 'eid', title:'装备ID'},
                        {field: 'uid', width:170,title:'唯一ID'},
                        {field: 'eidName', title:'装备名',templet:function (row) {
                                return getEquipName(row.eid);
                            }},
                        {field: 'zbsx', title:'装备属性',templet:'#zbsx'},
                        {field: 'clmx', title:'材料明细',templet:"#clmx"},
                        {field: 'lv', title:'精炼等级',templet:function (row) {
                                return row.old_lv+"=>"+row.new_lv;
                            }},
                        {field: 'result_type', title:'精炼结果',templet:function (row) {
                                if (row.result_type === 0) return '不变'
                                if (row.result_type === 1) return '升级'
                                if (row.result_type === 2) return '降级'
                                if (row.result_type === 3) return '消失'
                            }}
                    ]],
                    limits: [10, 15, 20, 25, 50, 100],
                    limit: 15,
                    page: true,
                    skin: 'line'
                });

                // 监听搜索操作
                form.on('submit(data-search-btn)', function (data) {
                    var searchData = data.field;
                    //执行搜索重载
                    table.reload('currentTableId', {
                        page: {
                            curr: 1
                        }
                        , where:searchData
                    }, 'data');
                    return false;
                });

            });
        }
    })

</script>
</body>
</html>